package com.powernode.controller;

import com.powernode.dto.Result;
import com.powernode.entity.Order;
import com.powernode.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/oms/orders")
public class OrderController {
    @Autowired
    private OrderService service;

    /**
     * 预览订单
     */
    @PostMapping("/preview")
    public Result<Order> previewOrder(@RequestBody Map<Long,Integer> map){
        return Result.success(service.previewOrder(map));
    }

    /**
     * 创建订单
     */
    @PostMapping
    public Result<Order> createOrder(@RequestBody@Validated Order order){
        return Result.success("创建订单成功",service.createOrder(order));
    }
}
